<?php
include("db.inc");

$name = $_POST['loginName'];
$pass = $_POST['passwd'];
$user_details = mysql_query("SELECT * FROM users where username='".$name."' AND password='".$pass."'");
if (mysql_num_rows($user_details) == 1) {
	$user_details = mysql_fetch_array($user_details);
	$_SESSION['User']['id'] = $user_details['id'];
	$_SESSION['User']['name'] = $user_details['username'];
	$_SESSION['User']['email'] = $user_details['email'];
	header('Location: index.php?page=profile.php');
} else {
	header('Location: index.php?page=registration.php');
}
?>